package br.com.winesys.geta.databinding.componentBinder;

import java.util.Arrays;
import java.util.List;
import br.com.winesys.geta.databinding.ComponentBinder;
import br.com.winesys.geta.databinding.component.table.TableViewer;

public final class TableViewerBinder implements ComponentBinder<TableViewer<Object>> {

	private static final ComponentBinder<TableViewer<Object>> INSTANCE = new TableViewerBinder();

	public static ComponentBinder<TableViewer<Object>> getInstance() {
		return INSTANCE;
	}

	private TableViewerBinder() {
	}

	@Override
	public Object read(TableViewer<Object> component) {
		return Arrays.asList(component.getValues());
	}

	@Override
	public void write(TableViewer<Object> component, Object value) {
		List<Object> list = (List<Object>) value;
		component.setValues(list);
	}
}
